
/**
 * @param {number[]} nums
 * @return {number[]}
 */
var sortArray = function (nums) {
    for (let i = 1; i < nums.length; i++) {
        let preIndex = i - 1
        let current = nums[i]
        while (preIndex >= 0 && current < nums[preIndex]) {
            nums[preIndex + 1] = nums[preIndex]
            preIndex--
        }
        nums[preIndex + 1] = current
    }
    return nums
};
let arr = [1, 8, 9, 5, 10, 3, 6, 2, 8, 21, 13]
console.log(sortArray(arr));